import { request } from '@umijs/max';

// 查点券
export function getIndex(params) {
  return request('/chdstore/User/ShopIndex', {
    method: 'GET',
    params,
  });
}

// 订单历史
export function getOrderList(params) {
  return request('/chdstore/User/Order', {
    method: 'GET',
    params,
  });
}

// 结算页
export function getShopCart() {
  return request('/chdstore/Shop/Cart', {
    method: 'GET',
  });
}

// 删除
export function deleteCart(id) {
  return request('/chdstore/Shop/Cart/del/' + id + '/1', {
    method: 'GET',
  });
}

// 登录
export function Login(ticket) {
  return request('/chdstore/User/Login?ticket=' + ticket, {
    method: 'GET',
  });
}

// 道具搜索
export function getCategory(id) {
  return request('/chdstore/Shop/Category?keyword=' + id, {
    method: 'GET',
  });
}

// 添加
export function add(id) {
  return request('/chdstore/Shop/Cart/add/' + id, {
    method: 'GET',
  });
}

// 结算
export function Exchange(data) {
  return request('/chdstore/Shop/Exchange', {
    method: 'POST',
    data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

// 马服/哈密瓜
const obj = {
  哈密瓜: {
    AreaId: 1,
    AreaName: '上海电信',
    ServerId: 8,
    ServerName: '哈密瓜',
    R: Math.random(),
  },
  马服: {
    AreaName: 'wegame专区',
    R: Math.random(),
  },
};

// 选区服
export function changearea() {
  return request('/chdstore/User/changearea', {
    method: 'POST',
    params: obj['哈密瓜'],
  });
}
